package ch.rheintalconnection.sysventory.businessServices;

import java.net.UnknownHostException;
import java.sql.Timestamp;
import java.util.List;

import ch.rheintalconnection.sysventory.domain.Client;
import ch.rheintalconnection.sysventory.domain.Computer;
import ch.rheintalconnection.sysventory.domain.NIC;
import ch.rheintalconnection.sysventory.domain.OperatingSystem;
import ch.rheintalconnection.sysventory.domain.Printer;
import ch.rheintalconnection.sysventory.domain.Processor;
import ch.rheintalconnection.sysventory.domain.Program;
import ch.rheintalconnection.sysventory.domain.ScanEntry;
import ch.rheintalconnection.sysventory.dto.ComputerDto;
import ch.rheintalconnection.sysventory.dto.LogicalDiskDto;
import ch.rheintalconnection.sysventory.dto.NicDto;
import ch.rheintalconnection.sysventory.dto.OperatingSystemDto;
import ch.rheintalconnection.sysventory.dto.PrinterConfigurationDto;
import ch.rheintalconnection.sysventory.dto.PrinterDto;
import ch.rheintalconnection.sysventory.dto.ProcessorDto;
import ch.rheintalconnection.sysventory.dto.ProgramDto;
import ch.rheintalconnection.sysventory.technicalServices.IHostScanner;

public class DomainHostScanner {
	
	IHostScanner hostScanner;
	
	public DomainHostScanner(IHostScanner hostScanner) {
		
		this.hostScanner = hostScanner;
		
	}
	
	public ScanEntry scan() throws UnknownHostException {
		
		NicDto nicDto = hostScanner.scanNic();
		ComputerDto computerDto = hostScanner.scanComputer();
		LogicalDiskDto logicalDiskDto = hostScanner.scanLogicalDisk();
		OperatingSystemDto operatingSystemDto = hostScanner.scanOperatingSystem();
		ProcessorDto processorDto = hostScanner.scanProcessor();
		List<PrinterDto> printerDtos = hostScanner.scanPrinters();
		List<PrinterConfigurationDto> printerConfigurationDtos = hostScanner.scanPrinterConfigurations();
		List<ProgramDto> programDtos = hostScanner.scanPrograms();
		
		DtoToDomainConverter dtoToDomainConverter = new DtoToDomainConverter();
		Client client = dtoToDomainConverter.toClient(nicDto);
		Computer computer = dtoToDomainConverter.toComputer(computerDto, logicalDiskDto);
		NIC nic = dtoToDomainConverter.toNic(nicDto);
		OperatingSystem os = dtoToDomainConverter.toOperatingSystem(operatingSystemDto);
		Processor processor = dtoToDomainConverter.toProcessor(processorDto);
		List<Printer> printers = dtoToDomainConverter.toPrinters(printerDtos, printerConfigurationDtos);
		List<Program> programs = dtoToDomainConverter.toPrograms(programDtos);
		
		ScanEntry scanEntry = new ScanEntry(new Timestamp(0), client, computer, nic, os, processor, printers, programs);
		return scanEntry;
	}

	

	

	

	

}
